package com.woniuxy.sportsdaili;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class JdkProxyFactory {
    public Object createProxyObject(Object obj) {
        Object o = Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(),
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        //前置增强
                        System.out.println("怪兽帅文强挑衅雷珉奥特曼");

                        Object aaa = method.invoke(obj, args);
                        //后置增强
                        System.out.println("怪兽帅文强被打的满面桃花开");
                        return aaa;
                    }
                });
        return o;
    }
}
